/**
 * Description:
 * Class Name:SynchronizedMethodDrawTest
 * Date:2022/5/6 16:12
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第16章_多线程._16_5_同步线程._16_5_3_同步方法;

class SynchronizedMethodDrawThread extends Thread{
    private SynchronizedMethodAccount account;
    private double drawAmount;
    public SynchronizedMethodDrawThread(String name, SynchronizedMethodAccount account, double drawAmount){
        super(name);
        this.account = account;
        this.drawAmount = drawAmount;
    }
    @Override
    public void run() {
        account.draw(800);
    }
}

public class SynchronizedMethodDrawTest {
    public static void main(String[] args) {
        var x = new SynchronizedMethodAccount("1234567", 1000);
        new SynchronizedMethodDrawThread("甲", x, 800).start();
        new SynchronizedMethodDrawThread("乙", x, 800).start();
    }
}
